var maxSunArray = function (nums) {
    let pre = 0, maxRes = nums[0];
    nums.forEach(function (value) {
        pre = Math.max(value, pre + value);
        maxRes = Math.max(maxRes, pre);
    });
    return maxRes;
}